package StudyCode.summary.regularexpressionsmatch;

/**
 * 版权所有 科技与人文(www.tah1986.com)
 */
public class MatchingStringAgainstPattern {
	public static void main(String[] args) {
		String regex = ".@.";
		MatchingStringAgainstPattern.matchIt("a@k", regex);
		MatchingStringAgainstPattern.matchIt("webmaster@mypkg.com", regex);
		MatchingStringAgainstPattern.matchIt("r@j", regex);
		MatchingStringAgainstPattern.matchIt("a%N", regex);
		MatchingStringAgainstPattern.matchIt(".@.", regex);
	}

	public static void matchIt(String str, String regex) {
		if (str.matches(regex)) {
			System.out.println(str + " 匹配正则表达式 " + regex);
		} else {
			System.out.println(str + " 不匹配正则表达式 " + regex);
		}
	}
}
